package com.icavy.yousha.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.icavy.yousha.BusinessException;
import com.icavy.yousha.dao.UserDAO;
import com.icavy.yousha.entity.User;
import com.icavy.yousha.service.UserService;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Resource
    UserDAO userDAO;

    @Override
    public void login(User user) {
        String email = user.getEmail();
        String password = user.getPassword();

        if (!userDAO.check(email, password)) {
            throw new BusinessException("login.userNotExist");
        }
    }

    @Override
    public void register(User user) {
        userDAO.save(user);
    }

}
